package main

import (
	"bytes"
	"encoding/binary"
	"encoding/hex"
	"fmt"
	"math"
)

func main() {

	var ss = "c1abe5ce4cfe4340"
	s1, err := hex.DecodeString(ss)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%x -> %f: \n", s1, bytesToFloat64(string(s1)))

	var f float64 = 39.986719
	a(f)

}

func a(f float64) {

	var buffer bytes.Buffer

	err := binary.Write(&buffer, binary.LittleEndian, f)

	if err != nil {
		panic(err)
	}

	fmt.Printf("%f -> %x: \n", f, buffer.Bytes())
	bb := buffer.Bytes()
	fmt.Printf("%x -> %f: \n", bb, bytesToFloat64(string(bb)))

}

func bytesToFloat64(b string) float64 {
	bits := binary.LittleEndian.Uint64([]byte(b))
	return math.Float64frombits(bits)
}
